/*
 * @Author: szx
 * @Date: 2022-03-25 13:01:03
 * @LastEditTime: 2022-03-25 13:21:35
 * @Description:
 * @FilePath: \leetcode\剑指offer\44\44.js
 */
/**
 * @param {number} n
 * @return {number}
 */
var findNthDigit = function (n) {
    let digit = 1,
        start = 1,
        count = 9;
    while (n > count) {
        n -= count;
        start *= 10;
        digit += 1;
        count = 9 * start * digit;
    }
    num = start + Math.floor((n - 1) / digit);
    num = num.toString();
    return num[(n - 1) % digit];
};
console.log(findNthDigit(11));
